package com.gwnet.cabinet.controller;

import com.gwnet.cabinet.client.ApiClient;
import com.gwnet.cabinet.domian.base.Result;
import com.gwnet.cabinet.domian.bo.GetBoxStatusBO;
import com.gwnet.cabinet.domian.bo.ManagerBoxesBO;
import com.gwnet.cabinet.domian.bo.OpenBoxBO;
import com.gwnet.cabinet.domian.bo.TakeBoxBO;
import com.gwnet.cabinet.domian.vo.BoxVO;
import com.gwnet.cabinet.domian.vo.OpenBoxVO;
import com.gwnet.cabinet.domian.vo.TakeBoxVO;
import com.gwnet.common.core.domain.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 外卖柜控制层
 * @author: WangLiang
 * @date: 2024/7/22 15:02
 */
@RequestMapping("/api")
@RestController
public class ApiController {

    private final ApiClient apiClient;

    @Autowired
    public ApiController(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /**
     * 放入开箱
     * @param openBoxBO 放入参数
     * @return
     */
    @PostMapping("/openBox")
    public ResponseResult<OpenBoxVO> openBox(@RequestBody OpenBoxBO openBoxBO){
        OpenBoxVO openBoxVO = apiClient.openBox(openBoxBO);
        return ResponseResult.success(openBoxVO);
    }


    /**
     * 取出开箱
     * @param takeBoxBO 取出参数
     * @return
     */
    @PostMapping("/takeBox")
    public ResponseResult<TakeBoxVO> takeBox(@RequestBody TakeBoxBO takeBoxBO){
        TakeBoxVO takeBoxVO = apiClient.takeBox(takeBoxBO);
        return ResponseResult.success(takeBoxVO);
    }

    /**
     * 管理箱门
     * @param managerBoxesBO
     * @return
     */
    @PostMapping("/managerBoxes")
    public ResponseResult<Result> managerBoxes(@RequestBody ManagerBoxesBO managerBoxesBO){
        Result result = apiClient.managerBoxes(managerBoxesBO);
        return ResponseResult.success(result);
    }

    /**
     * 获取箱门的状态
     * @param getBoxStatusBO
     * @return
     */
    @PostMapping("/getBoxStatus")
    public ResponseResult<List<BoxVO>> getBoxStatus(@RequestBody GetBoxStatusBO getBoxStatusBO){
        List<BoxVO> boxStatus = apiClient.getBoxStatus(getBoxStatusBO);
        return ResponseResult.success(boxStatus);
    }




}
